package action;

import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;

import pojo.UserProfile;

import com.opensymphony.xwork2.ActionSupport;

import dao.UserDAO;

public class LoginAction extends ActionSupport implements RequestAware, SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5197440947811652388L;
	
	//private static final Logger logger = Logger.getLogger(LoginAction.class);
	
	private Map<String, Object> request;
    private Map<String, Object> session;
    
    @Autowired  
    private UserDAO UserDAO;   
    
	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;
	}

	public void setRequest(Map<String, Object> arg0) {
		this.request = arg0;
	}
	
	public String login()
	{
		return "login";
	}
	
	public String loginfailed()
	{
		request.put("errorlogin", "Email or Password is incorrect !!!");
		return "loginfailed";
	}
	
	public String loginsuccess()
	{
		return "loginsuccess";
	}
	
	public String logout()
	{
		session.remove("lastname");
		session.remove("isAdmin");
		return "logout";
	}
	
	/*public String execute() {
		
        return SUCCESS;
		//return ERROR;
    }*/

}
